﻿
Partial Class UCDownload
    Inherits System.Web.UI.UserControl

    Public Sub Display(f As CFile)
        If f.IsHtm AndAlso f.Product.Files.HasPdfOrWord Then
            Me.Visible = False
            Exit Sub
        End If

        lnkText.Text = f.FileNameAndSizeShort
        lnkText.ToolTip = f.FileNameAndSize
        lnkText.NavigateUrl = CConfig.DropboxUrl(f.FileName)

        Dim p As CProduct = f.Product
        Dim sb As New StringBuilder(p.ProductName)
        If Not p.IsEnglish Then
            sb.Append("-").Append(p.ProductNameChineseSimplified)
        End If
        sb.Append(IO.Path.GetExtension(f.FileName))
        sb.Append(" (").Append(CUtilities.FileSize(f.FileSize)).Append(")")
        lnkText.Text = sb.ToString
    End Sub
    Public Sub Display(p As CProduct, vimeo As Boolean)
        Dim sb As New StringBuilder(p.ProductName)
        If Not p.IsEnglish Then
            sb.Append("-").Append(p.ProductNameChineseSimplified)
        End If
        If Not p.IsSet Then sb.Append(".mp4")
        lnkText.Text = sb.ToString
        lnkText.ToolTip = p.ProductName
        If p.IsSet Then
            If vimeo Then
                lbl.Text = " (vimeo channel)"
                lnkText.NavigateUrl = p.VideoUrl_VimeoChannel
                lnkText.Font.Bold = True
            Else
                lbl.Text = " (youtube playlist)"
                lnkText.NavigateUrl = p.VideoUrl_YouTubePlaylist
                lnkText.Font.Bold = True
            End If
        Else
            If vimeo Then
                lbl.Text = " (vimeo)"
                lnkText.NavigateUrl = IIf(p.IsSet, p.VideoUrl_VimeoChannel, p.VideoUrl_Vimeo)
            Else
                lbl.Text = " (youtube)"
                lnkText.NavigateUrl = IIf(p.IsSet, p.VideoUrl_YouTubePlaylist, p.VideoUrl_YouTube)
            End If
        End If
        lnkText.Target = "_blank"
    End Sub

    Public Sub Display(heading As String)
        bullet.Style.Add("list-style-type", "none")
        bullet.Style.Add("margin-left", "-15px")
        bullet.Style.Add("padding-top", "10px")
        lblHead.Text = heading
    End Sub

    Public Sub Display(heading As String, notes As String)
        Display(heading)
        lbl.Text = notes
    End Sub

    Public Sub Display(url As String, heading As String, notes As String)
        lnkText.Text = heading
        lnkText.NavigateUrl = url
        lnkText.Target = "_blank"
        lbl.Text = notes
    End Sub

End Class
